<?php require_once("includes/secure.php"); ?>
<script type="text/javascript">
$(document).ready(function() {
//var filename = window.location.href.substr(window.location.href.lastIndexOf("/")+1);
//filename = filename.substr(0, filename.length-4); 


var filename = window.location.href.substring(window.location.href.lastIndexOf("/")+1,window.location.href.lastIndexOf(".php"))
  console.log(filename);
//	$("#menu-item-205").addClass("menu-item-105");
  $("li").removeClass("current-menu-item");
  $("#"+ filename).addClass("current-menu-item");
 // alert( $("#"+filename	).html());

});	
</script>

<?php

if (isset($_POST['person_number']) && isset($_POST['pass_word'])  )
{
	require("includes/openConnection.php");

	$sql  = "SELECT * FROM agent,person ";
	$sql .= "WHERE agent.person_number=person.person_number AND  agent.person_number = '{$_POST['person_number']}' ";
	$sql .= "AND  agent.pass_word = '{$_POST['pass_word']}' ";
	$sql .= "LIMIT 1";	
	$result = mysql_query($sql);


	if ($r =mysql_fetch_assoc($result)) 
	{
          
            $_SESSION['person_number']=$r['person_number'];
            $_SESSION['companyname']=$r['companyname'];
            $_SESSION['mehiron_number']=$r['mehiron_number'];
            $_SESSION['metria']=$r['metria'];
            $_SESSION['full_name']=$r['firstname']. " " .$r['lastname'] ;
	}
	require("includes/closeConnection.php");
	?>
<script type="text/javascript">
self.location="agentReports.php";

</script>
<?php	
}
else if (isset($_POST['logout'])) 
{
	if (isset($_SESSION['person_number']))
	{
	unset($_SESSION['person_number']);
	}
	// session_unset();	 
}
?>
<header style="margin-bottom: 100px;" >
<div class="container_12 clearfix">

    <div id="logo" class="logo" dir="rtl" align="right" style="margin-bottom: 15px" >
        <span style="top: 25px;position: relative;">  <img id="" src="images/logo.png"></img></span>
        <div style="display: inline-block;">
     <a  title="Best Business Solutions" class="site-name">ר.א צ'ק אין בע"מ		</a>
   
    <p class="tagline">ר.א צ'ק אין - פתרונות לסוכן ביטוח</p>
    <p class="tagline" style="margin: 5px 0;">טלפון: <strong class="color-1">04-9522823</strong> פקס: <strong class="color-1">076-5100392</strong></p> 
     <p class="tagline">ת.ד: <strong class="color-1">3139 נהריה</strong> מייל: <strong class="color-1">r.a.chakin@bezeqint.net</strong></p>   
        </div>
    </div>

    
    
    <div style="
    width: 250px;
    display: inline-block;
    height: 100px;
    position: absolute;
    left: 0;
    text-align: center;
">
        <h2 style="
    text-align: center;
">הודעות מערכת</h2>
    <marquee scrolldelay="270" direction="up" style="height: 100px;">
        <p style="text-align: center">הודעה 1 </p><br>
        <p style="text-align: center">הודעה 2 </p><br>
        <p style="text-align: center">הודעה 3 </p><br>
        <p style="text-align: center">הודעה 4 </p><br>
        <p style="text-align: center">הודעה 5 </p><br>
        <p style="text-align: center">הודעה 6 </p><br>
    </marquee>
    </div>
    
    
    
    <nav class="primary">
        <ul id="topnav" class="sf-menu">
           <li id="contact" class="menu-item menu-item-type-post_type menu-item-object-page  page_item page-item-203 current_page_item menu-item-205">
           <a href="contact.php"><strong><em>צור קשר</em></strong></a></li>
            <?php if (isset($_SESSION['person_number'])) {?> 
          <?php if (isset($_SESSION['metria']) && $_SESSION['metria']==1) {?>
           <li id="metriaAgentAmlot" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-105">
           <a href="metriaAgentAmlot.php"><strong><em>עמלות מטריה</em></strong></a></li>
            <?php } ?>
           <li id="agentAmlot" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-105">
           <a href="agentAmlot.php"><strong><em>עמלות סוכן</em></strong></a></li>
          
           <li id="agentReports" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-105">
           <a href="agentReports.php"><strong><em>דוחות סוכן</em></strong></a></li>
           
           <li id="agentNotifications" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-105">
           <a href="agentNotifications.php"><strong><em>התראות סוכן</em></strong></a></li>
            <?php } ?>
            <?php if (!isset($_SESSION['person_number'])) {?>
           <li id="agentLogin" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-105">
           <a href="agentLogin.php"><strong><em>כניסת סוכנים</em></strong></a></li>
           <?php } ?>
           <?php if (isset($_SESSION['person_number'])) {?>
           <li id="logOut" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-105">
           <a onclick='$("#logoutForm").submit()' ><strong><em>התנתקות מהמערכת</em></strong></a></li>
            <?php } ?>
           <li id="home" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-17 current-menu-item">
           <a href="home.php"><strong><em>אודותינו</em></strong></a></li>
        </ul>
    </nav>
</div><!--.container_12-->
</header>

   <h2>
         

         <?php
         if (isset($_SESSION['person_number'])) {
            if (isset($_SESSION['full_name'])) {
                echo "שלום סוכן" ." " . $_SESSION['full_name'] ." "   ;
                 echo "מספר" ." " . $_SESSION['person_number']  ;
              
            }
         }?> 
   
     </h2>
<form id="logoutForm"  action="agentLogin.php" method="post" >
<input name="logout" value=""  size="40" type="hidden">
</form>	